<template>
  <a-form ref="formRef" :model="formData" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
    <a-row>
      <a-col :span="24">
        <a-form-item label="反馈内容" name="fknr">
          <a-textarea v-model:value="formData.fknr" placeholder="请输入内容" />
        </a-form-item>
      </a-col>
      <a-col :span="24">
        <a-form-item label="附件" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }">
          <uploader
            ref="uploaderRef"
            v-model:urls="formData.fjdz"
            v-model:names="formData.fjmc"
            :max-count="9"
            :col-span="6"
            accept="image,video,audio,doc"
            filePath="zlgl"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-form>
</template>

<script>
import Uploader from '@gis/lib/components/Uploader/upload.vue';
import { instructionFeedback } from '@gis/lib/api';
import { handleFormResult } from '@gis/lib/utils/resolver.js';

export default {
  name: 'replyOrSign',
  components: { Uploader },
  props: {
    id: { type: String, default: '' },
  },
  data() {
    return {
      rules: {
        fknr: { required: true, message: `请输入内容` },
      },
      labelCol: { span: 5 },
      wrapperCol: { span: 19 },
      formData: {},
    };
  },
  methods: {
    async onOk() {
      await this.$refs.uploaderRef.checkUploads();
      await this.$refs.formRef.validate();
      if (typeof this.$attrs.onBeforeFeedback === 'function') {
        await this.$attrs.onBeforeFeedback();
      }
      const params = Object.assign({}, this.formData, { id: this.id });
      return handleFormResult(await instructionFeedback(params));
    },
  },
};
</script>
